<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>待办事项</title>
</head>
<script src="//unpkg.com/vue/dist/vue.js"></script>
<link rel="stylesheet"
	href="https://unpkg.com/element-ui/lib/theme-chalk/index.css" />
<link rel="stylesheet"
	href="./resources/css/sweetalert2.css" />
<script src="//unpkg.com/element-ui/lib/index.js"></script>
<script src="./resources/js/jquery.min.js"></script>
<script src="./resources/js/sweetalert2.min.js"></script>
<body>
<div id="mainApp">
  <el-container style="padding-top:20px;">
	  <el-header style="heighe:10px;">
		  <el-row :gutter="24">
			<el-col :span="8" :xs="8" :sm="8" :md="8" :lg="8">
				<el-breadcrumb class="breadcrumb-inner">
					<el-breadcrumb-item><h2>待办事项</h2></el-breadcrumb-item>
				</el-breadcrumb>
			</el-col>
		  </el-row>
	  </el-header>
	  <el-main>
	  	  <el-card calss="box-card">
	  	  	<el-row :gutter="24">
		  		<el-col :span="8" :xs="8" :sm="8" :md="8" :lg="8">
		  			<span><h4>待办事项</h4></span>
		  		</el-col>
		  	</el-row>
		  </el-card>
		  <el-card calss="box-card" style="margin-top:20px">
			  <el-row style="overflow-x:hidden;">
		  		<template>
				  <el-table :data="tableData" style="width:980%;margin:15px auto">
				    <el-table-column prop="processInstanceId" label="流程ID" >
				    </el-table-column>
				    <el-table-column prop="userId" label="用户ID" >
				    </el-table-column>
				    <el-table-column prop="reason" label="原因" >
				    </el-table-column>
				    <el-table-column label="操作" >
				    	<template slot-scope="scope">
				    		 <el-button type="primary" @click="handelApp(scope.row)">审批</el-button>
				    	</template>
				    </el-table-column>
				  </el-table>
			  	</template>
			  </el-row>
		  </el-card>
	  </el-main>
  </el-container>
  
  <el-dialog title="审批" :visible.sync="dialogFormVisible">
	  <el-form>
	    <el-form-item label="审批结果" >
	      <el-select v-model="appFlag" placeholder="请选择审批结果">
	        <el-option label="通过" value="Y"></el-option>
	        <el-option label="拒绝" value="N"></el-option>
	      </el-select>
	    </el-form-item>
	  </el-form>
	  <div slot="footer" class="dialog-footer">
	    <el-button @click="handelClose">取 消</el-button>
	    <el-button type="primary" @click="submitApp">确 定</el-button>
	  </div>
 </el-dialog>
</div>
</body>
<script>
new Vue({
		el:"#mainApp",
	    data:{
	    	tableData: [],
	    	dialogFormVisible:false,
	    	appFlag:"",
	    	row:""
	    },
	    mounted:function(){
	    	this.pendingList();
	    },
	    methods: {
	      pendingList(){
			  var _this = this;
			  $.get("appro/queryPendingApproval").then(data=>{
				  console.log(data);
				  _this.tableData = data;
	    	  },response=>{
	    		  alert(response.responseJSON.message);
	    	  });
		  },
		  handelApp(row){
			  this.dialogFormVisible=true;
			  this.row = row;
		  },
		  handelClose(){
		    	this.appFlag="";
		    	this.dialogFormVisible=false;
		  },
		  submitApp(){
			  $.post("appro/complateApproval",{
				  processDefinitionId:this.row.processDefinitionId,
				  taskDefinitionKey:this.row.taskDefinitionKey,
				  taskId:this.row.taskId,
				  approveFlag:this.appFlag
			  }).then(data=>{
				  if(data.code=="1"){
					  swal("审批成功!");
					  this.pendingList();
				  }
	    	  },response=>{
	    		  alert(response.responseJSON.message);
	    	  });
		  }
	    }
	  });
</script>
</html>